package com.suray.basic.wcs.plc.enums;

import com.suray.basic.wcs.utils.IBaseEnum;

import java.io.Serializable;

public enum Location implements IBaseEnum<Serializable> {
    /**
     * 提升机左侧
     */
    LEFT(1, "左"),
    /**
     * 提升机右侧
     */
    RIGHT(2, "右"),
    /**
     * 提升机内部
     */
    INSIDE(0, "中"),

    /**
     * 输送线在高位
     */
    UP(3, "Up"),

    /**
     * 输送线在低位
     */
    DOWN(4, "Down"),

    /**
     * 移栽方向
     */
    X_INCREASE_DIR(5, "X增大方向"),
    X_MINUS_DIR(6, "X减小方向"),
    Y_INCREASE_DIR(7, "Y增大方向"),
    Y_MINUS_DIR(8, "Y减小方向"),
    ;
    private int code;
    private String description;

    private Location(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return this.code;
    }

    public static Location parseLocationCode(int locationCode) {
        Location[] locations = Location.values();
        for (Location location1 : locations) {
            if (location1.code == locationCode) {
                return location1;
            }
        }
        throw new IllegalArgumentException("位置参数异常");
    }

    @Override
    public String toString() {
        return description;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public Integer getVal() {
        return code;
    }

    @Override
    public Serializable getValue() {
        return code;
    }
}
